fileIn "stryker_curve.ms"
fileIn "2826_6_mount.ms"

baseHoleRadius = (3.2/2) --hole width is 3 mm using 4.5 for fudge factor
baseHoleWidth = baseHoleRadius*2
closerHoleDistance = 46.23 + baseHoleWidth
fartherHoleDistance = 68.74+ baseHoleWidth
frontToBackDistance = 32.84 + baseHoleWidth
firstHoleYoffset = 5.6 --distance from hole closest to back of mount to back of mount


wallthickness = 1.1
--motor mount specifics
motormountZ = 26
motorBoxWidth = 27
motorBoxHeight = motorBoxWidth / 2.0 + motormountZ
totalLength = 50

function BoolSubKeepEdges SubObj1 SubObj2 =
(
max modify mode 
proboolean.setoperandA SubObj1
proboolean.SetBoolOp SubObj1 2 -- set subtract boolean op
proboolean.SetPlanarEdgeRemoval SubObj1 1
proboolean.setDisplayResult SubObj1 true
proboolean.setoperandB SubObj1 SubObj2 2 0 
proboolean.SetPlanarEdgeRemoval SubObj1 1	
)

--EXECUTE BOOLEAN w/ Imprint

vertCone = OilTank radius:motorBoxHeight Cap_Height:(totalLength) height:(totalLength*2.0) Blend:0 sides:24 Height_Segments:1 Smooth_On:1 Slice_On:1 Slice_From:0 Slice_To:180 mapcoords:1 transform:(matrix3 [1,0,0] [0,0,-1] [0,-1,0] [0,totalLength*1.5,0.01]) isSelected:on
scale vertCone [0.5,1,1]
diff = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:-60 radius:(totalLength*3.0) mapcoords:on transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,totalLength/2,0]) isSelected:on

BoolSubKeepEdges vertCone diff
select vertCone

proboolean.setoperandA vertCone
ProBoolean.SetPlanarEdgeRemoval $ 0
ProBoolean.GetPlanarEdgeRemoval vertCone


ProBoolean.SetOperandA vertCone
ProBoolean.SetPlanarEdgeRemoval vertCone 0
ProBoolean.SetUpdateMode vertCone 3
ProBoolean.SetOperandB vertCone diff 2 0
ProBoolean.SetUpdateMode vertCone 0


ProBoolean.CreateBooleanObject vertCone diff 2 0 1; 
ProBoolean.SetPlanarEdgeRemoval vertCone 1
diff = createStrykerCurve();
ProBoolean.CreateBooleanObject vertCone diff 2 0 1;
vertCone.pos.Z -= 0.01


--to work around the stupidities of maxscript, we make a copy of part we want to copy from
plug = copy vertCone
diff = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:totalLength width:motorBoxWidth height:motorBoxWidth mapcoords:on pos:[0,-wallthickness,(motorMountZ - motorBoxWidth/2.0)] isSelected:on
--then make the bounding box

ProBoolean.CreateBooleanObject plug diff 1 0 0;--get the intersection and assign it to plug

diff = copy plug--now copy the plug

ProBoolean.CreateBooleanObject vertCone diff 2 0 1; --subtract copy of plug from original

base = makeStrykerCurve();
motorHoles = createMotorMount()
 
motorHoles.pos.Z = motormountZ
motorHoles.pos.Y += (totalLength/2.0)
 
motorHoles.rotation.x_rotation = 90

ProBoolean.CreateBooleanObject vertCone motorHoles 2 0 1; --subtract copy of plug from original
ProBoolean.CreateBooleanObject vertCone base  0 0 1; --subtract copy of plug from original

-- hole1 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(-0.5*closerHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset),(-0.5*wallthickness*3)] isSelected:on
-- hole2 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(0.5*closerHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset),(-0.5*wallthickness*3)] isSelected:on
-- hole3 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(0.5*fartherHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset - frontToBackDistance),(-0.5*wallthickness*3)] isSelected:on
-- hole4 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(-0.5*fartherHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset - frontToBackDistance),(-0.5*wallthickness*3)] isSelected:on
-- ProBoolean.CreateBooleanObject vertCone hole1 2 0 1
-- ProBoolean.CreateBooleanObject vertCone hole2 2 0 1
-- ProBoolean.CreateBooleanObject vertCone hole3 2 0 1
-- ProBoolean.CreateBooleanObject vertCone hole4 2 0 1


-- select #(vertCone,plug)
-- motorGroup = group selection name: "tempGroup"
-- select motorGroup
-- motorGroup.pivot = [0,totalLength/2,0]

-- rotate motorGroup (angleaxis 270 [1,0,0])
-- ungroup motorGroup
-- vertCone.pos.Y = 0
-- plug.pos.Z -= wallThickness
-- plug.pos.Y = 28

